﻿
Public Class cVendedor
    Private ldrVend As dsTercero.TER_VENDEDORRow
    Private lITipoVend As cTipoVendedor
    Sub New(ByVal idVendedor As String)
        Try
            Dim DaVen As New dsTerceroTableAdapters.TER_VENDEDORTableAdapter
            Dim DtVen As dsTercero.TER_VENDEDORDataTable = DaVen.GetDataByIdVendedor(idVendedor)
            If DtVen.Rows.Count > 0 Then
                ldrVend = DtVen.Rows(0)
                lITipoVend = New cTipoVendedor(ldrVend.IDTIPOVENDEDOR)
            Else
                Throw New Exception("No existe vendedor para este id, favor verificar e intentar de nuevo")
            End If
        Catch ex As Exception
            cError.SalvaError(ex, "Samuel")
            Throw ex
        End Try
    End Sub
    Public ReadOnly Property idVendedor() As String
        Get
            Return ldrVend.IDVENDEDOR
        End Get
    End Property

    Public ReadOnly Property idZona() As String
        Get
            Return ldrVend.IDZONA
        End Get
    End Property

    Public ReadOnly Property idTipoVendedor() As String
        Get
            Return ldrVend.IDTIPOVENDEDOR
        End Get
    End Property

    Public ReadOnly Property acumulaComision() As Boolean
        Get
            Return ldrVend.ACUMULACOMISION
        End Get
    End Property

    Public ReadOnly Property iTipoVendedor() As cTipoVendedor
        Get
            Return lITipoVend
        End Get
    End Property

    Protected Overrides Sub Finalize()
        lITipoVend = Nothing
        ldrVend = Nothing
    End Sub
End Class
